<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // let arr = ['a','b','c'];

        // let res = arr.find(function(v){
        //     // console.log(v);
        //     // return v === 'c';
        //     return v === 'd';
        // });

        // console.log(res);


        let arr = [
            {
                name:"老王",
                score:60
            },
            {
                name:"小李",
                score:70
            },
            {
                name:"小王",
                score:80
            },
            {
                name:"小高",
                score:90
            },
        ];

        
        // 数组中某一项 - 条件判断返回如果为真 
        let res = arr.find(function(v){
            console.log(v);

           return v.name === '老王';
        });

        console.log(res);

        // 第一次返回为真的结果
        let resIndex = arr.findIndex(function(v){
            console.log(v);

            return v.name === '老王2';

        });

        // -1 代表没有找到符合条件的项
        // console.log(resIndex); //-1





    </script>
</body>
</html>